package com.ha7419x.rest;

import com.ha7419x.service.IUserService;
import com.ha7419x.vo.Dept;
import com.ha7419x.vo.User;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
public class DeptRest {

    @Resource
    private IUserService userService;
    @Resource
    private DiscoveryClient client; //eureka 发现服务

    @RequestMapping(value = "/user/discover", method = RequestMethod.GET)
    public Object discover(){
        return this.client;
    }

    @RequestMapping(value = "/user/get/{id}", method = RequestMethod.GET)
    public Object get(@PathVariable("id") Long id){
        return this.userService.get(id);
    }

    @RequestMapping(value = "/user/add", method = RequestMethod.POST)
    public Object get(@RequestBody User user){
        return this.userService.add(user);
    }

    @RequestMapping(value = "/user/addWithNo", method = RequestMethod.POST)
    public Object addWithNo(@RequestBody User user){
        return this.userService.addWithNo(user);
    }

    @RequestMapping(value = "/user/list", method = RequestMethod.GET)
    public Object get(){
        return this.userService.list();
    }
}
